Skip to content

Make cctz::ParseDateTime() return NULL on failure#347

Merged
mkruskal-google merged 1 commit into
google:masterfrom
higher-performance:malformed-date-time
Jul 14, 2026
Merged

Make cctz::ParseDateTime() return NULL on failure#347
mkruskal-google merged 1 commit into
google:masterfrom
higher-performance:malformed-date-time

Conversation

@higher-performance

Copy link
Copy Markdown
Collaborator

Prevents uninitialized data from being returned when the input is malformed (say, when the footer is \nPST8PDT,M3\n).

@mkruskal-google mkruskal-google self-assigned this Jul 10, 2026
Comment thread src/time_zone_posix.cc Outdated
@higher-performance
higher-performance force-pushed the malformed-date-time branch 3 times, most recently from ae3f739 to 0944ced Compare July 11, 2026 03:03
Comment thread src/time_zone_posix.cc Outdated
@mkruskal-google
mkruskal-google requested a review from devbww July 11, 2026 03:44
Comment thread src/time_zone_posix_test.cc Outdated

TEST(TimeZonePosix, ParsePosixSpec) {
PosixTimeZone zone;
EXPECT_FALSE(ParsePosixSpec("PST8PDT7", &zone));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for introducing the test.

I don't expect you do this, but, if you have the inclination, this now affords the opportunity to add a more extensive test suite.

Prevents uninitialized data from being returned when the input is malformed
@mkruskal-google
mkruskal-google merged commit 75b181e into google:master Jul 14, 2026
13 checks passed
@higher-performance
higher-performance deleted the malformed-date-time branch July 14, 2026 18:50
devbww added a commit to devbww/cctz that referenced this pull request Jul 16, 2026
Now that google#347 has introduced `time_zone_posix_test`, expand it to
cover all of `ParsePosixSpec()`, including success and failure cases.

Also:
 - Update the BNF for `ParsePosixSpec()` after google#347 moved the
   comma into `datetime`.
 - Update the Open Group URL for the TZ environment-variable
   specification.
derekmauro pushed a commit that referenced this pull request Jul 17, 2026
Now that #347 has introduced `time_zone_posix_test`, expand it to
cover all of `ParsePosixSpec()`, including success and failure cases.

Also:
 - Update the BNF for `ParsePosixSpec()` after #347 moved the
   comma into `datetime`.
 - Update the Open Group URL for the TZ environment-variable
   specification.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants